<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <script src="esl.js"></script>
        <script src="config.js"></script>
        <script src="lib/facePrint.js"></script>
    </head>
    <body>
        <style>
            html, body, #main {
                width: 100%;
                height: 100%;
            }
        </style>
        <div id="info"></div>
        <div id="main"></div>
        <script>

            require([
                'echarts',
                'echarts/chart/line',
                'echarts/component/legend',
                'echarts/component/grid',
                'echarts/component/tooltip',
                'echarts/component/visualMap'
            ], function (echarts) {

                var chart = echarts.init(document.getElementById('main'));

                var xAxisData = [];
                var data1 = [];

                var base = Math.round(Math.random() * 100);
                for (var i = 0; i < 1000; i++) {
                    xAxisData.push('类目' + i);
                    base += Math.round(Math.random() * 10 - 5);
                    data1.push(base);
                }

                chart.setOption({
                    visualMap: {
                        // min: 0,
                        // max: 50,
                        // FIXME piecewise 的 symbol 颜色有问题
                        type: 'piecewise',
                        outOfRange: {
                            color: '#aaa'
                        },
                        pieces: [{
                            lte: 120,
                            gt: 100,
                            color: 'red'
                        }, {
                            lt: 80,
                            gt: 70,
                            // color: 'blue'
                        }, {
                            lt: 90,
                            gt: 50,
                            // color: 'blue'
                        }, {
                            lte: 40,
                            // color: 'blue'
                        }]
                        // pieces: [{
                        //     gte: 0,
                        //     color: 'red'
                        // }, {
                        //     lt: 0,
                        //     color: 'blue'
                        // }]
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'line'
                        }
                    },
                    xAxis: {
                        data: xAxisData,
                        boundaryGap: false
                    },
                    yAxis: {},
                    series: [{
                        name: 'line',
                        type: 'line',
                        stack: 'all',
                        symbol: 'circle',
                        areaStyle: { normal: {} },
                        symbolSize: 10,
                        data: data1
                    }]
                });
            });

        </script>
    </body>
</html>